# -*- coding: UTF-8 -*-

import pymysql

Host = '127.0.0.1'
User = 'root'
Password = ''
dbname='find_job'

db = pymysql.connect(Host,User,Password,dbname,charset="utf8")
cursor = db.cursor()

# zhiwei = scrapy.Field()
# gongsi = scrapy.Field()
# qian = scrapy.Field()
# miaoshu = scrapy.Field()
# dizhi = scrapy.Field()
# id = scrapy.Field()
class Sql:
    @classmethod
    def Insert_data(cls,zhiwei,gongsi,qian,miaoshu,dizhi,id,xingzhi,guimo,hangye):
        # print(dizhi)
        # sql = "INSERT INTO 51job('51Id','zhiwei','gongsi','qian','miaoshu','dizhi') VALUES (%(id)s,%(zhiwei)s,%(gongsi)s,%(qian)s,%(miaoshu)s,%(dizhi)s)"
        sql = "INSERT INTO 51job(`51Id`,`zhiwei`,`gongsi`,`qian`,`miaoshu`,`dizhi`,`xingzhi`,`guimo`,`hangye`) VALUES (%(id)s,%(zhiwei)s,%(gongsi)s,%(qian)s,%(miaoshu)s,%(dizhi)s,%(xingzhi)s,%(guimo)s,%(hangye)s)"
        # print(sql)
        value = {
            'id': id,
            'zhiwei': zhiwei,
            'gongsi': gongsi,
            'qian': qian,
            'miaoshu': miaoshu,
            'dizhi': dizhi,
            'xingzhi': xingzhi,
            'guimo': guimo,
            'hangye': hangye
        }

        print(value)
        cursor.execute(sql, value)
        db.commit()
